package game;

import java.util.LinkedList;

import carddeck.Card;
import carddeck.Rank;
import carddeck.Suit;

public class GameStruct {
	private class PlayerStruct {
		public boolean isActive;
		public boolean isCPU;
		public LinkedList<CardStruct> playerCards;
		public int waitTime;
		public String name;
		
		public PlayerStruct(String pName) {
			isActive = true;
			isCPU = false;
			waitTime = -1;
			name = pName;
			playerCards = new LinkedList<>();
		}
	}
	
	private class CardStruct {
		public Rank cardRank;
		public Suit cardSuit;
		public boolean isJoker() {
			if(cardRank==Rank.UNDEFINED||cardSuit==Suit.UNDEFINED)
				return true;
			else
				return false;
		}
		
		public CardStruct(Rank rank, Suit suit) {
			cardRank = rank;
			cardSuit = suit;
		}
	}
	
	private PlayerStruct [] players;
	
	public GameStruct() {
		players = new PlayerStruct[4];
		for(int i=0;0<4;i++)
			players[i] = new PlayerStruct("Gracz "+(i+1));
	}
	
	//editing players data
	public void givePlayerACard(int playerNum, Rank rank, Suit suit) {
		players[playerNum].playerCards.add(new CardStruct(rank, suit));
	}
	public void setPlayersWaitTime(int playerNum, int waitTime) {
		players[playerNum].waitTime=waitTime;
	}
	public void setPlayersName(int playerNum, String newName) {
		players[playerNum].name=newName;
	}
	public void setPlayerActive(int playerNum, boolean bActive) {
		players[playerNum].isActive=bActive;
	}
	public void setPlayerCPU(int playerNum, boolean bCPU) {
		players[playerNum].isCPU=bCPU;
	}
	
	//accessing players data
	public LinkedList<CardStruct> getPlayersCards(int playerNum) {
		return players[playerNum].playerCards;
	}
	public int getPlayersWaitTime(int playerNum) {
		return players[playerNum].waitTime;
	}
	public String getPlayersName(int playerNum) {
		return players[playerNum].name;
	}
	public boolean isPlayerActive(int playerNum) {
		return players[playerNum].isActive;
	}
	public boolean isPlayerCPU(int playerNum) {
		return players[playerNum].isCPU;
	}
}
